package com.order.application.service.converter;

import com.order.application.dto.OrderDTO;
import com.order.domain.models.OrderEntity;
import com.order.userinterfaces.vo.OrderVO;

/**
 * @Author 刘志伟
 * @create 2022/9/26 14:05
 */
public class OrderEntityConverter {

    public static OrderEntity orderDTO2OrderEntity(OrderDTO orderDTO) {
        if (orderDTO == null)
            return OrderEntity.builder().build();

        OrderEntity entity = OrderEntity.builder().cargoes_id(orderDTO.getCargoesID())
                .order_no(orderDTO.getOrderNO())
                .price(orderDTO.getPrice())
                .create_datetime(orderDTO.getCreateDatetime()).build();
        return entity;
    }

    public static OrderDTO entity2OrderDTO(OrderEntity entity) {
        if (entity == null)
            return OrderDTO.builder().build();
        OrderDTO dto = OrderDTO.builder().cargoesID(entity.getCargoes_id())
                .orderNO(entity.getOrder_no())
                .price(entity.getPrice())
                .createDatetime(entity.getCreate_datetime()).build();
        return dto;
    }
}
